package io.geekidea.boot.allocation.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.geekidea.boot.allocation.dto.AllocationExcel;
import io.geekidea.boot.allocation.dto.addAllocation;
import io.geekidea.boot.allocation.entity.Allocation;
import io.geekidea.boot.allocation.query.AllocationQuery;
import io.geekidea.boot.allocation.query.MaterialQuery;
import io.geekidea.boot.materials.entity.Materials;
import io.geekidea.boot.otherstores.query.total;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AllocationMapper extends BaseMapper<Allocation> {


    List<Allocation> getList(AllocationQuery allocationQuery);

    List<AllocationExcel> getListExcel(AllocationQuery allocationQuery);

    total getTotal(AllocationQuery allocationQuery);

    @Insert("insert into tb_allocation(transferNum,areaOutId,storesOutId,areaInId,storesInId,materialTypeNum,materialNum,money,creatorUser,creatorTime) values (#{transferNum},#{areaOutId},#{storesOutId},#{areaInId},#{storesInId},#{trTypeNum},#{Num},#{money},#{creatorUser},now())")
    int addAllocation(addAllocation addAllocation);


    List<Materials> getWL(MaterialQuery materialQuery);


    @Insert("insert into tb_store_materials(numbers,name,code,taxsh,availableInventory,lockInventory,secureInventory,stockage,typeid,supplierId,warehouseId,materialsource,areaId,storesId,total_stock,createdBy,updatedBy) " +
            "values (#{numbers},#{materialName},#{materialCode},#{materialSn},#{availableInventory},#{lockInventory},#{secureInventory},#{stockage},#{typeid},#{supplierId},#{warehouseId},#{materialsource},#{areaId},#{storesId},#{total_stock},#{createdBy},#{updatedBy})")
    int addWL();

    @Select("select * from tb_allocation where id = #{id}")
    Allocation getAllById(Integer id);



}
